﻿Chenxin.UI.BargainMarket = Chenxin.extend(Chenxin.UI.PageCommon, {
    autoInitForm: false,
    actionUrl: '/service/logic/BargainMarket.ashx',
    createSearch: function() {
        return new Chenxin.UI.BargainMarketSearch({
            scope: this
        });
    },
    createGrid: function() {
        return new Chenxin.UI.JsonGrid({
            actionUrl: this.actionUrl + '?op=getlist',
            id: 'search_table',
            renderTo: 'search_table',
            hasCheckBox: false,
            modelId: 'ContractId',
            height: 300,
            cellBorder: true,
            scope: this,
            columns: {
                ContractCode: {
                    head: '成交编号',
                    width: 120
                },
                ContractDate: {
                    head: '成交日期',
                    width: 80,
                    renderer: function(val, field, row) {
                        return val.split(' ')[0];
                    }
                },
                BusinessType: {
                    head: '成交类型',
                    width: 80,
                    renderer: function(val, field, row) {
                        if (val == 10) {
                            return '买卖';
                        }
                        else if (val == 20)
                            return '租赁';
                        else if (val == 30)
                            return '零散';
                        else if (val == 40)
                            return '其他';
                    }
                },
                Region: {
                    head: '区域',
                    width: 80
                },
                Community: {
                    head: '小区名称',
                    width: 120
                },
                HouseAddress: {
                    head: '地址',
                    width: 180
                },
                BargainPrice: {
                    head: '成交价格',
                    width: 120
                },
                BargainUnitPrice: {
                    head: '单价',
                    width: 120
                },
                Area: {
                    head: '面积',
                    width: 120
                },
                HouseType: {
                    head: '房型',
                    width: 80
                },
                CompleteYear: {
                    head: '竣工年份',
                    width: 100
                },
                HouseUse: {
                    head: '房屋用途',
                    width: 100
                },
                BuildingType: {
                    head: '房屋类型',
                    width: 100
                },
                Fitment: {
                    head: '装修情况',
                    width: 100
                }
            }
        });
    },
    initEvent: function() {
        var _this = this;
        /*************************事件：起始日期得到焦点************************/
        $('#keyword').defText({
            deftxt: '输入地址/小区名称'
        });
    },
    initComponent: function() {
        Chenxin.UI.BargainMarket.superclass.initComponent.call(this);
    }
});

/**
*查询面板
*/
Chenxin.UI.BargainMarketSearch = Chenxin.extend(Chenxin.UI.SearchCommon, {
    id: 'search',
    initEvent: function() {
        var _this = this;

        //查询按钮
        $('#btn_search').click(function() {
            _this.scope.reloadGrid();
        });
    },
    createComboList: function() {
        var combl = new Chenxin.UI.StructComboList({
            tbxWidth: 65
        });
        //建筑类型
        var comboBuildingType = new Chenxin.UI.ParameterCombo({
            containerId: '#BuildingType',
            name: 'BuildingType',
            key: 'Building.Type',
            inModelType: 'txt',
            tbxWidth: 65
        });
        //区域
        var comboRegion = new Chenxin.UI.ParameterCombo({
            name: 'Region',
            containerId: '#Region',
            key: 'System.Region',
            tbxWidth:65,
            inModelType: 'txt',
            param: { filter: 'bycity' }
        });
        //房屋用途
        var comboHouseUse = new Chenxin.UI.ParameterCombo({
            containerId: '#HouseUse',
            name: 'HouseUse',
            key: 'House.Use',
            inModelType: 'txt',
            tbxWidth: 65
        });
        //成交类型
        var combotype = new Chenxin.UI.Combo({
            containerId: '#divType',
            tbxWidth: 58,
            name: 'BusinessType',
            items: [{ txt: '买卖', val: '10' }, { txt: '租赁', val: '20' }, { txt: '全部', val: '0'}]
        });
        var structs = combl.comboList;
        structs.push(comboBuildingType);
        structs.push(comboRegion);
        structs.push(comboHouseUse);
        structs.push(combotype);
        return structs;
    },
    initComponent: function() {
        Chenxin.UI.BargainMarketSearch.superclass.initComponent.call(this);
    }
});

getcity = true; //设置需要获取城市下拉框数据

$(document).ready(function() {
    var BargainMarket = new Chenxin.UI.BargainMarket();
});